package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.zzyl.base.PageResponse;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.mapper.NursingLevelMapper;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NursingLevelServiceimpl implements NursingLevelService {

    @Autowired
    private NursingLevelMapper nursingLevelMapper;
    @Override
    public List<NursingLevelVo> GetAllPlanLevel() {
        return nursingLevelMapper.getAllLevel();
    }

    @Override
    public void addlevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.toBean(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.addlevel(nursingLevel);
    }

    @Override
    public PageResponse<NursingLevelVo> getPage(Integer pageNum, Integer pageSize, String name, Integer status) {
        PageHelper.startPage(pageNum,pageSize);
        Page<NursingLevel> nursingLevels = nursingLevelMapper.getPage(name,status);
        return PageResponse.of(nursingLevels,NursingLevelVo.class);
    }

    @Override
    public NursingLevelVo getByid(Long id) {
        return nursingLevelMapper.getByid(id);
    }

    @Override
    public void updatelevel(NursingLevelDto nursingLevelDto) {
        NursingLevel nursingLevel = BeanUtil.toBean(nursingLevelDto, NursingLevel.class);
        nursingLevelMapper.updatelevel(nursingLevel);
    }

    @Override
    public void deleteByid(Long id) {
        nursingLevelMapper.deleteByid(id);
    }

    @Override
    public void updatestatus(Long id, Integer status) {
        nursingLevelMapper.updatestatus(id,status);
    }
}
